package my.iterator.composite;

public class ComponentTest {

    public static void main(String[] args) {
        /**
         * 维护一个 树型的结构，每个节点可能是 菜单或菜单项，但是都一视同仁为 MenuComponent
         *
         * 如果需要在外部遍历树节点， 查找到符合需求的节点呢？  那么需要一个外部迭代器
         *
         */
        MenuComponent pancakeHouseMenu = new Menu("煎饼屋菜单","煎饼屋菜单");
        MenuComponent dinerMenu = new Menu("餐厅菜单","对象村餐厅菜单");
        MenuComponent dessertMenu = new Menu("甜点菜单","甜点菜单");
        MenuComponent allMenu = new Menu("所有菜单","所有菜单");
        allMenu.add(pancakeHouseMenu);
        allMenu.add(dinerMenu);

        pancakeHouseMenu.add(new MenuItem("玉米煎饼", "德美亚玉米", true, 2.99));
        pancakeHouseMenu.add(new MenuItem("虾仁煎饼", "舟山虾仁", false, 10));
        pancakeHouseMenu.add(new MenuItem("山东煎饼", "山东白面", true, 2.7));

        dessertMenu.add(new MenuItem("甜甜圈", "特甜", true, 1.7));
        dessertMenu.add(new MenuItem("冰淇淋", "特甜", true, 1.7));

        dinerMenu.add(new MenuItem("小鸡炖蘑菇", "东北小鸡", false, 40.8));
        dinerMenu.add(new MenuItem("猪肉炖粉条", "农家土猪", false, 50.9));
        dinerMenu.add(new MenuItem("大米饭", "铁力大米", true, 1));
        MenuComponent fruit = new Menu("果盘","");
        fruit.add(new MenuItem("西瓜", "西瓜", true, 10));
        dessertMenu.add(fruit);
        dinerMenu.add(dessertMenu);

        //服务员
        Waitress waitress = new Waitress(dinerMenu);
        //服务员报菜名
        waitress.printMenu();


        //外部迭代器 找到所有 素食菜单
        waitress.printVegetarianMenu();


    }
}
